package com.ruiyian.bridge.info.service.impl;

import com.ruiyian.bridge.info.mapper.VibrationAccelerationMapper;
import com.ruiyian.bridge.info.service.VibrationAccelerationService;
import com.ruiyian.bridge.project.domain.vo.DataAnalysisDto;
import com.ruiyian.bridge.project.domain.vo.DataAnalysisVo;
import com.ruiyian.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author chong
 * @email 673426164@qq.com
 * @create 2022/6/17
 * Desc: 振动加速度
 */
@Service
public class VibrationAccelerationServiceImpl implements VibrationAccelerationService {

    @Autowired
    private VibrationAccelerationMapper vibrationAccelerationMapper;

    /**
     * 当前时刻数据
     * @param addr
     * @param macaddr
     * @return
     */
    @Override
    public DataAnalysisVo getNowMinData(String addr, String macaddr) {
        String now = DateUtils.dateTimeNow();
        String nextDate = DateUtils.getNextDate(2, new Date(), -8, null);
        return vibrationAccelerationMapper.getNowMinData(addr, macaddr,nextDate,now);
    }
    /**
     * 根据时间类型查询数据
     * @param dto
     * @return
     */
    @Override
    public List<DataAnalysisVo> queryByDateType(DataAnalysisDto dto) {
        return vibrationAccelerationMapper.queryByDateType(dto);
    }
}
